$SERVER["socket"] == ":${HTTPS_PORT}" {
    ssl.engine = "enable",
    ssl.pemfile = "${META_DIR}/ssl/server.pem",
}
$HTTP["scheme"] == "http" {
    $HTTP["remote-ip"] != "127.0.0.1" {
        $HTTP["remote-ip"] != "[::1]" {
            $HTTP["host"] =~ "^(.*?)(:\d+)?$" {
                url.redirect = ("" => "https://%1:${HTTPS_PORT}${url.path}${qsa}")
            }
        }
    }
}
